package com.ruoyi.technician.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.technician.domain.TechnicianAuthentication;
import com.ruoyi.technician.service.ITechnicianAuthenticationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资质管理Controller
 * 
 * @author ruoyi
 * @date 2025-04-07
 */
@RestController
@RequestMapping("/technicianAuthentication/technicianAuthentication")
public class TechnicianAuthenticationController extends BaseController
{
    @Autowired
    private ITechnicianAuthenticationService technicianAuthenticationService;

    /**
     * 查询资质管理列表
     */
    @PreAuthorize("@ss.hasPermi('technicianAuthentication:technicianAuthentication:list')")
    @GetMapping("/list")
    public TableDataInfo list(TechnicianAuthentication technicianAuthentication)
    {
        startPage();
        List<TechnicianAuthentication> list = technicianAuthenticationService.selectTechnicianAuthenticationList(technicianAuthentication);
        return getDataTable(list);
    }

    /**
     * 导出资质管理列表
     */
    @PreAuthorize("@ss.hasPermi('technicianAuthentication:technicianAuthentication:export')")
    @Log(title = "资质管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TechnicianAuthentication technicianAuthentication)
    {
        List<TechnicianAuthentication> list = technicianAuthenticationService.selectTechnicianAuthenticationList(technicianAuthentication);
        ExcelUtil<TechnicianAuthentication> util = new ExcelUtil<TechnicianAuthentication>(TechnicianAuthentication.class);
        util.exportExcel(response, list, "资质管理数据");
    }

    /**
     * 获取资质管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('technicianAuthentication:technicianAuthentication:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(technicianAuthenticationService.selectTechnicianAuthenticationById(id));
    }

    /**
     * 新增资质管理
     */
    @PreAuthorize("@ss.hasPermi('technicianAuthentication:technicianAuthentication:add')")
    @Log(title = "资质管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TechnicianAuthentication technicianAuthentication)
    {
        return toAjax(technicianAuthenticationService.insertTechnicianAuthentication(technicianAuthentication));
    }

    /**
     * 修改资质管理
     */
    @PreAuthorize("@ss.hasPermi('technicianAuthentication:technicianAuthentication:edit')")
    @Log(title = "资质管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TechnicianAuthentication technicianAuthentication)
    {
        return toAjax(technicianAuthenticationService.updateTechnicianAuthentication(technicianAuthentication));
    }

    /**
     * 删除资质管理
     */
    @PreAuthorize("@ss.hasPermi('technicianAuthentication:technicianAuthentication:remove')")
    @Log(title = "资质管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(technicianAuthenticationService.deleteTechnicianAuthenticationByIds(ids));
    }
}
